// @ts-nocheck
/**
 * this is demo toutes to show route params and how to use it
 * also you can write project all routes in this page
 */
import Test from '@/[...all].vue'
function removeQueryParams(to) {
  if (Object.keys(to.query).length) return { path: to.path, query: {}, hash: to.hash }
}

function removeHash(to) {
  if (to.hash) return { path: to.path, query: to.query, hash: '' }
}
// 路由内的所有函数都是只针对对应的路由
/* eslint-disable */
const routes = [
  {
    path: '/home',
    redirect: '/',
    components: { default: Test, other: Test },
    meta: {},
    alias: ['/index', '/main'],
  },
  {
    path: '/users/:id',
    redirect: () => ({
      // 定义重定向方法
      name: 'user',
      params: { id: String(Math.round(Math.random() * 100)) },
    }),
    component: Test,
    beforeEnter: [removeQueryParams, removeHash],
    props: { default: to => ({ waited: to.meta.waitedFor }) }, // 将路由上的参数直接传递给组件，如果全部替换，直接使用props: true
    children: [{ path: 'list', component: Test }],
  },
  {
    path: '/about',
    component: Test,
    beforeEnter: (to, from) => {
      // reject the navigation
      return false
    },
  },
]
